<!-- 审批详情-班组长详情 -->
<template>
	<view style="padding-bottom: 180rpx;">
		<view class="flex justify-center align-center py-3">
			<u--image v-if="obj.status==1" src="/static/images/ui/salary/wait.png" width="154rpx" height="154rpx"></u--image>
			<u--image v-if="obj.status==2" src="/static/images/ui/salary/pass.png" width="154rpx" height="154rpx"></u--image>
			<u--image v-if="obj.status==3" src="/static/images/ui/salary/reject.png" width="154rpx" height="154rpx"></u--image>
		</view>
		<view class="p-3">
			<view class="bt-block">
				<bg-cell2 label="姓名" :value="obj.createUserName"></bg-cell2>
				<bg-cell2 label="身份证号" :value="obj.idCardNo"></bg-cell2>
				<bg-cell2 label="手机号" :value="obj.phone"></bg-cell2>
				<bg-cell2 label="项目名称" :value="obj.projectName"></bg-cell2>
				<bg-cell2 label="申领物资" :value="obj.materialName"></bg-cell2>
				<bg-cell2 label="申领数量" :value="obj.applyCount"></bg-cell2>
				<bg-cell2 label="单件价格" :value="obj.unitPrice"></bg-cell2>
				<bg-cell2 :border="false" label="合计总价" :value="obj.totalAmount"></bg-cell2>
			</view>
			<view class="bt-block mt-3 px24py30">
				<bg-title>
					<text>温馨提示</text>
				</bg-title>
				<view class="mt-3 font-14 text-grey2 font-normal">
					申领人领用的本物资如有损坏丢失，需照本申领单约定照价赔偿，此费要从申领人劳动报酬中扣除，领取人同意请在下方申领签字
				</view>
			</view>
			<view class="bt-block mt-3">
				<bg-cell2 :border="false" label="申领人签字">
					<template slot="value">
						<u--image width="380rpx" height="154rpx" :src="obj.signedImg"></u--image>
					</template>
				</bg-cell2>
			</view>
			<view class="bt-block mt-3">
				<bg-cell2 :border="false" label="物资照片" >
					<template slot="extra">
						<bg-images :imgList="obj.materialImgList"></bg-images>
					</template>
				</bg-cell2>
			</view>
			<view class="bt-block mt-3 px24py30">
				<bg-title>
					<text>流程节点图</text>
				</bg-title>
				<view class="py-3">
					<bg-step :list="authList"></bg-step>
				</view>
			</view>
		</view>
		<view class="bt-footer" v-if="obj.status==1&&$auth.hasRoleOr(['team',  'project'])">
			<view class="flex" style="width: 100%;">
				<view class="flex-1 px-2">
					<bg-btn @click="pass" :plain="true">通过</bg-btn>
				</view>
				<view class="flex-1 px-2">
					<bg-btn @click="unpass">不通过</bg-btn>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { getApply, auditApply } from '../../../api/apply'
	export default {
		data() {
			return {
				id:'',
				obj:{},
				authList:[]
			}
		},
		onLoad(options) {
			this.id = options.id
			this.getData()
		},
		methods: {
			getData(){
				getApply(this.id).then(res=>{
					this.obj = res.data
					this.authList  = [
						{auditUserName:this.obj.createUserName, auditTime:this.obj.createTime},
						{status: this.obj.status,auditUserName:this.obj.auditUserName, 
						auditTime:this.obj.auditTime, auditRole:"项目管理员"}
					]
				})
			},
			pass(){
				let _data = {id:this.id, status:2}
				auditApply(_data).then(res=>{
					uni.$emit("apply-refresh", true)
					this.$modal.msgSuccess("操作成功")
					this.$tab.navigateBackDelay()
				})
			},
			unpass(){
				let _data = {id:this.id, status:3}
				auditApply(_data).then(res=>{
					uni.$emit("apply-refresh", true)
					this.$modal.msgSuccess("操作成功")
					this.$tab.navigateBackDelay()
				})
			},
			getImgUrl(fileName){
				if(fileName?.startsWith('http')){
					return fileName
				}else {
					return `${getApp().globalData.config.baseUrl}${getApp().globalData.config.ossUrl}?objectName=${fileName}`
				}
			}
		}
	}
</script>

<style>

</style>
